<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../script/lokijs.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../script/db.js" type="text/javascript" charset="utf-8"></script>
		<script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<ul class="mui-table-view" id="list">

		</ul>

		<script src="../script/template.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
		<script type="text/html" id="listTem">
			{{each}}
			<li class="mui-table-view-cell">{{$value.name}}</li>
			{{/each}}
		</script>
		<script type="text/javascript">
			db = new loki('data');
			db.loadDatabase({}, function() {
				var c = db.getCollection('answers');
				if (c == null) {
					c = db.addCollection('answers');
				}
//				for (var i = 0; i < 10; i++) {
//					var data = {
//						'qid': i,
//						'answer': '[0]',
//						'result': 'wrong',
//						'lesson': 2
//					}
//					c.insert(data);
//				}
				$line = c.findOne({'qid':1});
				
//				$line.answer="right";
				console.log(JSON.stringify($line));
//				c.update($line);
				db.saveDatabase();
			});
//			var q = {
//				'id': 1
//			};
			 //			var res = APP.loki('findOne', q);
//			var res = APP.loki('get', 3);
//			console.log(JSON.stringify(res));
			 ////						alert('lokijs');
			 //			//			var loki = require('lokijs'),
			 //							db = new loki('test.json'),
			 //							db2 = new loki('test.json');
			 ////'						var users = db.addCollection('users');
			 ////						for (var i = 0;i<1000;i++) {
			 ////							users.insert({
			 ////								name: 'joe'+i,
			 ////								data: i
			 ////							});
			 ////						}
			 ////						db.saveDatabase();'
			 //						db2.loadDatabase({}, function() {
			 //							var users2 = db2.getCollection('users')
			 //							var res = users2.findOne({'data':2});
			 //							alert(JSON.stringify(res));
			 ////							var res = users2.where(
			 ////								function(obj){
			 ////									return obj.data>2&&obj.data<200;
			 ////								}
			 ////							);
			 ////							var html = template('listTem',res);
			 ////							document.getElementById("list").innerHTML=html;
			 ////							mui.each(users2.data,function(index,item){
			 ////							  console.log(item.name);
			 ////							});
			 //			//				console.log(users2.data);
			 //						});
			 //						 //		var db = new loki("data.json");
			 //						 //		db.loadDatabase();
			 //						 //		var col = db.getCollection('data');
			 //						 //		if(col==null){
			 //						 //			db.addCollection("data");
			 //						 //		}
			 //						 //		col.insert({name:"jike",msg:"hello"});
			 //						 //		db.save();
		</script>
	</body>

</html>